<?
include_once "../main.php";

if(isset($fu))
{
	$q1 = "select epass, CompanyEmail from job_employer_info where ename = \"$_POST[ename]\"";
	$r1 = mysql_query($q1) or die(mysql_error());
	$a1 = mysql_fetch_array($r1);

	if(empty($a1[0]) || empty($a1[1]))
	{
	echo "<br><br><br><center><span class=TNA>There is no registered user with username: <span class=BlackLink> $_POST[ename] </span></span><br><br><a class=BlackLink href=\"javascript:window.history.go(-1);\">back</a></center>";
	}
	else
	{
		$to = $a1[CompanyEmail];
		$subject = "Your username/password for $_SERVER[HTTP_HOST]";
		$message = "Hello,\n here is your login information for http://$_SERVER[HTTP_HOST]\n\nUsername: $_POST[ename]\nPassword: $a1[epass]";
		$from = "From: $_SERVER[HTTP_HOST] <$aset[ContactEmail]>";

		mail($to, $subject, $message, $from);
		echo "<br><br><br><center><span class=BlackLink>Your login information was sent to $to <br><br><br>Click <a class=TNA href=\"PostJob.php\">here</a> to login.</span></center>";
	}
}
elseif(isset($fm))
{

	$q2 = "select ename, epass from job_employer_info where CompanyEmail = \"$_POST[EEmail]\"";
	$r2 = mysql_query($q2) or die(mysql_error());
	$a2 = mysql_fetch_array($r2);

	if(empty($a2[0]) || empty($a2[1]))
	{
	echo "<br><br><br><center> There is no registered user with email: <b> $_POST[EEmail] </b></center>";
	}
	else
	{
		$to = $_POST[EEmail];
		$subject = "Your username/password for $_SERVER[HTTP_HOST]";
		$message = "Hello,\n here is your login information for http://$_SERVER[HTTP_HOST]\n\nUsername: $a2[ename]\nPassword: $a2[epass]";
		$from = "From: $_SERVER[HTTP_HOST] <$aset[ContactEmail]>";

		mail($to, $subject, $message, $from);

		echo "<br><br><br><center> Your login information was sent to $to </center>";
	}
}
else
{
?>

<br>
<form method=post>
<table align=center width=460 class=BlackText>
<caption align=center class=HeaderClass>Password Recovery</caption>
<tr>
	<td>If you remember your username, but has forgot your password enter your username and in a few second will receive your password directly into the email you used at our site registration form.</td>
</tr>

<tr>
	<td>Username: <input type=text name=ename> <input type=submit name=fu value=Submit></td>
</tr>
</table>
</form>

<form action="<?=$PHP_SELF?>" method=post>
<table align=center width=470 class=BlackText>
<tr>
	<td>If you has forgot all your login information (username & password) but still remember the email you used at our site registration form, just enter it into the box and in a few seconds you will receive your login informstion. </td>
</tr>
<tr>
	<td>Email: <input type=text name=EEmail> <input type=submit name=fm value=Submit></td>
</tr>
</table>
</form>

<?
}
?>
<? include_once('../footer.php'); ?>